package com.iwinding.ladygg.ui.view;

import android.content.Context;
import android.util.AttributeSet;

import com.hyphenate.easeui.domain.EaseUser;
import com.hyphenate.easeui.widget.EaseContactList;
import com.iwinding.ladygg.R;
import com.iwinding.ladygg.ui.adapter.PromptContactAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hezhiyong on 2017/4/20.
 */

public class PromptContactList extends EaseContactList {


    public PromptContactList(Context context) {
        super(context);
    }

    public PromptContactList(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PromptContactList(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs);
    }

    public void setOnUserEvent(PromptContactAdapter.OnUserEvent onUserEvent){
        if(adapter!=null){
            ((PromptContactAdapter)adapter).setOnUserEvent(onUserEvent);
        }
    }

    @Override
    public void init(List<EaseUser> contactList){
        this.contactList = contactList;
        adapter = new PromptContactAdapter(context, R.layout.icane_prompt_row_contact, new ArrayList<EaseUser>(contactList));
        adapter.setPrimaryColor(primaryColor).setPrimarySize(primarySize).setInitialLetterBg(initialLetterBg)
                .setInitialLetterColor(initialLetterColor);
        listView.setAdapter(adapter);

        if(showSiderBar){
            sidebar.setListView(listView);
        }
    }

}
